package com.bort.system.view;

import com.bort.system.common.DataContainer;
import com.bort.system.model.Category;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;

public class CategoryItemView extends FlowPane {

    Label cateName;

    ImageView cateImage;

    Image image;

    Category data;

    public CategoryItemView(Category data) {
        this.data = data;
        this.setPrefHeight(56);
        this.setPrefWidth(42);
        this.setOrientation(Orientation.VERTICAL);

        image = new Image(DataContainer.loadImageUrl +data.getCategoryIcon());
        cateImage = new ImageView(image);
        cateImage.setFitHeight(36);
        cateImage.setFitWidth(38);
        this.getChildren().add(cateImage);

        cateName = new Label(data.getCategoryName());
        cateName.setPrefWidth(40);
        cateName.setPrefHeight(18);
        cateName.setAlignment(Pos.CENTER);
        this.getChildren().add(cateName);

    }

    public Category getData() {
        return data;
    }
}
